#!/usr/bin/env node

const cheerio = require('cheerio'),
      log = console.log,
      http = require('http'),
      https = require('https'),
      addUrl = 'http://www.meiju8.cc/movie/94657.html';
let movieURL = '',
    movieHref = '';
http.get(addUrl,(res) => {
        let result = '';
        res.on('data',(data)=>{
            result += data.toString('utf8'); 
        })
        res.on('end',()=>{ 
            let $ = cheerio.load(result);
            movieHref = $('body').find('.mn_list_li_movie>a').attr('href');
            movieURL = addUrl + '/' + movieHref;
        })

})
http.createServer((req,res) => {
  res.write(`
          <html>
             <meta charset = 'utf-8'>
             <head>video</head>
             <body>
                <button>播放</button>
                <a href='${movieURL}'>跳转</a>
             </body>
          </html>`); 
}).listen(3000);

